package SellCar.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import SellCar.pojo.Buy;
import SellCar.service.BuyBiz;
import SellCar.service.impl.BuyBizImpl;

public class LikeServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			response.setContentType("text/html;charset=utf-8");
			PrintWriter out = response.getWriter();
			HttpSession session = request.getSession();
			request.setCharacterEncoding("UTF-8");
			response.setCharacterEncoding("UTF-8");
			
			BuyBiz biz = new BuyBizImpl();
			String carName = new String(request.getParameter("carName").getBytes("iso-8859-1"),"utf-8");
			System.out.println(carName);
			List<Buy> carInfo = biz.getCarInfo(carName);
			session.setAttribute("carInfo", carInfo);
			response.sendRedirect("likeCar.jsp");
			
			
	}

}
